翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

New (C++) : ウィキペディア英語版
New and delete (C++)

In the C++ programming language, and are a pair of language constructs that perform dynamic memory allocation, object construction and object destruction.
==Overview==
Except for a form called the "placement new", the operator denotes a request for memory allocation on a process's heap. If sufficient memory is available, initialises the memory, calling object constructors if necessary, and returns the address to the newly allocated and initialised memory.〔(【引用サイトリンク】title=IBM Documentation describing C++'s operator new )〕〔(【引用サイトリンク】title=Microsoft Visual Studio operator new documentation )〕 A request, in its simplest form, looks as follows:
p = new T;
where is a previously declared pointer of type (or some other type to which a pointer can be assigned, such as a superclass of ). The default constructor for , if any, is called to construct a instance in the allocated memory buffer.
If not enough memory is available in the free store for an object of type , the request indicates failure by throwing an exception of type . This removes the need to explicitly check the result of an allocation.
The deallocation counterpart of is , which first calls the destructor (if any) on its argument and then returns the memory allocated by back to the free store. Every call to must be matched by a call to ; failure to do so causes memory leaks.〔
syntax has several variants that allow finer control over memory allocation and object construction. A function call-like syntax is used to call a different constructor than the default one and pass it arguments, e.g.,
p = new T(argument);
calls a single-argument constructor instead of the default constructor when initializing the newly allocated buffer.
A different variant allocates arrays of objects rather than single objects:
p = new T ();
This requests a memory buffer from the free store that is large enough to hold a contiguous array of objects of type , contiguously, and calls the default constructor on each elements of the array.
Memory allocated with the must be deallocated with the operator, rather than . Using the inappropriate form results in undefined behavior. C++ compilers are not required to generate a diagnostic message for using the wrong form.
The C++11 standard specifies an additional syntax,
p = new T() ;
that initializes each to .

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「New and delete (C++)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.